package com.dcd.util;

import com.cloopen.rest.sdk.CCPRestSmsSDK;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Random;

/*荣联云*/
@Component
public class VerificationCodeUtil {

    public static String send_verification_code() {

        Random random = new Random();// 随机四位数验证码
        String rd = String.valueOf(random.nextInt(10000 - 1000) + 1000);

        HashMap<String, Object> result = null;

        CCPRestSmsSDK restAPI = new CCPRestSmsSDK();

        restAPI.init("app.cloopen.com", "8883");// 初始化服务器地址和端口，格式如下，服务器地址不需要写https://
        restAPI.setAccount("8aaf07087f77bf96017f91283e810616", "09c2442677bf466da8972f094962feae");// 初始化主帐号和主帐号TOKEN
        restAPI.setAppId("8aaf07087f77bf96017f91283f86061c");// 初始化应用ID
        result = restAPI.sendTemplateSMS("18473030948", "1", new String[]{rd, "1"});

        if (!"000000".equals(result.get("statusCode")))
            return "false";
        return rd;
    }
}
